package com.gitee.sunshine.bean;

import com.gitee.sunshine.enums.DBTypeEnum;

public class DBContextHolder {

	private static final ThreadLocal<DBTypeEnum> contextHolder = new ThreadLocal<DBTypeEnum>();

	public static void set(DBTypeEnum dbType) {
		contextHolder.set(dbType);
	}

	public static DBTypeEnum get() {
		return contextHolder.get();
	}

	public static void master() {
		set(DBTypeEnum.WRITE);
	}

	public static void slave() {
		set(DBTypeEnum.READ);
	}
	
    public static void clear() {
        contextHolder.remove();
    }
}